<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\Alarm\Http\Request\Admin;

use Hyperf\Validation\Request\FormRequest;

/**
 * 报警记录验证数据类
 */
class RdAlarmWarnRecordRequest extends FormRequest
{
    /**
     * 场景配置
     */
    protected array $scenes = [
        'index' => [
            'id', 'broadcast_id', 'msg_id', 'rod_id', 'stand_id', 'type', 'warning_time', 'device_id', 'risk_level', 'title', 'content', 'msg_type', 'created_at', 'updated_at'
        ],
        'create' => [
            'broadcast_id', 'msg_id', 'rod_id', 'stand_id', 'type', 'warning_time', 'device_id', 'risk_level', 'title', 'content', 'msg_type'
        ],
        'update' => [
            'broadcast_id', 'msg_id', 'rod_id', 'stand_id', 'type', 'warning_time', 'device_id', 'risk_level', 'title', 'content', 'msg_type'
        ],
        'delete' => [ 'id', 'ids' ],
    ];

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            'broadcast_id' => 'integer|min:1',
            'msg_id' => 'integer|min:1',
            'rod_id' => 'integer|min:1',
            'stand_id' => 'integer|min:1',
            'type' => 'integer|min:1',
            'warning_time' => 'date',
            'device_id' => 'integer|min:1',
            'risk_level' => 'integer|min:1|max:255',
            'title' => 'string|max:255',
            'content' => 'string',
            'msg_type' => 'integer|in:1,2',
        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => '主键',
            'broadcast_id' => '广播id',
            'msg_id' => '消息id',
            'rod_id' => '装置id',
            'stand_id' => '站点id',
            'type' => '事件id',
            'warning_time' => '报警时间',
            'device_id' => '报警设备id',
            'risk_level' => '风险等级',
            'title' => '标题',
            'content' => '内容',
            'msg_type' => '消息类型',
        ];
    }

public function messages(): array
{
    return [
            'id.required' => '必填',
            'broadcast_id.required' => '必填广播id',
            'msg_id.required' => '必填消息id',
            'rod_id.required' => '必填装置id',
            'stand_id.required' => '必填站点id',
            'type.required' => '必填事件id',
            'warning_time.required' => '必填报警时间',
            'device_id.required' => '必填报警设备id',
            'risk_level.required' => '必填风险等级',
            'title.required' => '必填标题',
            'msg_type.required' => '必填消息类型',
            'msg_type.in' => '消息类型只能是1(雷达)或2(相机)',
    ];
}
}